home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1998 September
/
Macworld (1998-09).dmg
/
Shareware World
/
Info
/
For Developers
/
MacZoop 1.8.3
/
Required Classes
/
Z Headers
/
ZDefines.h
< prev
next >
Wrap
Text File
|
1998-07-10
|
5KB
|
181 lines
/*************************************************************************************************
*
*
* MacZoop - "the framework for the rest of us"
*
*
*
* ZDefines.h -- some handy constants, etc
*
*
*
*
*
* © 1996, Graham Cox
*
*
*
*
*************************************************************************************************/
#pragma once
#ifndef __ZDEFINES__
#define __ZDEFINES__
// standard basic resource IDs, etc.
#define kSleepTime 10 // number of ticks to give up to background programs
#define kUntitledWindowID 128 // resource ID of the main window template
#define kAppleMenuID 128 // ID of the apple menu
#define kFileMenuID 129 // ID of File menu
#define kEditMenuID 130 // ID of Edit menu
#define kShowAboutBox 1
#define kAboutBoxID 128
#define kStdMenubarID 128 // ID of the default MBAR resource for the main menu bar
#define kMiscStrListID 128
#define kExceptionAlertID 130
#define kMemoryLowAlertID 132
#define kAssertionAlertID 138
// save changes alert constants
#define kConfirmSaveAlertID 129
enum
{
kConfirmSave = 1,
kCloseNoSave,
kCloseCancel
};
// macros for extracting window/dialog objects from mac windows
#define IS_ZWINDOW_KIND 772 // in the 'kind' field of the window record
#define GetZWindow(w) ((((WindowPeek) w)->windowKind == IS_ZWINDOW_KIND) || \
(((WindowPeek) w)->windowKind == dialogKind))? \
(ZWindow*) GetWRefCon(w) : NULL
#define kStdScrollbarWidth 15
// handy object disposal macros
#define ForgetObject(p) { delete (p); (p) = NULL; }
#define ForgetThis() { delete this; }
// common useful macros
#define MIN( a, b ) ((a) < (b))? (a) : (b)
#define MAX( a, b ) ((a) > (b))? (a) : (b)
#define ABS( x ) (((x) < 0 )? -(x) : (x))
#define CMP( a, b ) ((a) < (b))? -1 : (((a) > (b))? 1 : 0 )
#define SGN( a ) (((a) < 0 )? -1 : 1 )
#define CLITERAL( x ) #x
#define PLITERAL( x ) CLITERAL( \p##x )
// can be passed tp SetCursorShape() to set cursor to qd.arrow:
#define ARROW_CURSOR 0
#define WIN_ARROW_CURSOR 199
// common non-ascii keys
#define TAB_KEY 0x09
#define RETURN_KEY 0x0D
#define ENTER_KEY 0x03
#define ESCAPE_KEY 0x1B
#define UP_ARROW_KEY 0x1E
#define DOWN_ARROW_KEY 0x1F
#define LEFT_ARROW_KEY 0x1C
#define RIGHT_ARROW_KEY 0x1D
#define BACKSPACE_KEY 0x08
// undefined and quiet exceptions
#define kUnknownExceptionErr 999
#define kSilentErr -1
#define kMacZoopParamErr 950
#define kMacZoopParamErr1 951
#define kMacZoopNULLPtrErr 952
#define kUnknownSignature '????'
// current MacZoop version number:
#define MACZOOP_VERSION 0x0183
// global structure provides some common gestalt results
typedef struct
{
Boolean supportsColour; // colour quickdraw available
Boolean hasDragManager; // drag manager available
Boolean hasFPU; // has a floating-point coprocessor
Boolean hasAppleEvents; // has apple events
Boolean hasAppearanceMgr; // has the appearance manager
Boolean hasQuickTime; // has QuickTime available
Boolean hasImgCompressionMgr; // the Image Compression Manager is available
Boolean hasNavigationServices; // Nav Services installed & available
short systemVersion; // current system version number
}
tMacInfo;
// handy basic pascal string utilities
void CopyPString( ConstStr255Param srcString, Str255 destString );
void ConcatPStrings( Str255 root, ConstStr255Param append );
void CopyPStringTrunc( ConstStr255Param srcString, Str255 destString, unsigned char ccLim );
void ConcatPStringsTrunc( Str255 root, ConstStr255Param append, unsigned char ccLim );
// static functions for setting up the global zoom FX source rect:
void SetGlobalZoomSource( Rect* aGlobalRect );
void SetLocalZoomSource( Rect* aLocalRect );
// standard function to determine if a GrafPort is colour or b/w
Boolean IsColourPort( GrafPtr aPort );
// utility function to set hilite mode for invert ops
void SetHiliteMode();
// check for drag manager including linkage check:
Boolean MacHasDM();
// Alert posting function that will handle notification if app suspended, Use wherever you would
// otherwise use Alert. Default flags give typical behaviour, you can pass others to modify
// behaviour.
typedef enum
{
ntMinimalAlert = 0,
ntAlertPlaySound = 1,
ntAlertDisplayMessage = 2,
ntAlertDefault = 3
}
NTAlertFlags;
// note that NotifyAlert assumes:
#define kApplicationIconSuiteID 128
#define kNotificationSoundID 128
// posting function- use it instead of Alert():
short NotifyAlert( const short alertID, NTAlertFlags flags = ntAlertDefault );
// simple delay function (try to avoid delays since they waste time!).
// MZWait will handle events while counting off the ticks, so can be more cooperative than
// MZDelay though less accurate due to event latency.
void MZDelay( short ticks );
void MZWait( unsigned short ticks );
#endif